//
//  LSZPraisePoetryAndSermonsVC.m
//  JKFuYinProject
//
//  Created by 九酷 on 2017/9/19.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LSZPraisePoetryAndSermonsVC.h"
#import "LCFloatingWindow.h"
#import "LSZPraisePoetryAndSermonsVC+LCAVPlay.h"
#import "JKSongsMessStatus.h"
#import "NetworkTool+LCAVPlay.h"

@interface LSZPraisePoetryAndSermonsVC ()
{
    NSInteger lastClickRow;//记录上次点击的是那个区

    NSInteger pageVideo;//讲道视频分页
    NSInteger videoType;//1大的  2小的
}
@property(nonatomic,strong) UIButton * typeChooseBut;
@property(nonatomic,assign) NSInteger cliclMoveWhereRow;//排行榜用
@end

@implementation LSZPraisePoetryAndSermonsVC
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    [LCFloatingWindow sharedInstance].hidden = NO;/////
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:YES];
    [LCFloatingWindow sharedInstance].hidden = YES;/////
    if(self.viewSharePopover.hidden == NO){
        self.viewSharePopover.hidden = YES;
        self.viewLow.hidden = YES;
        self.butCancel.hidden = YES;
    }
}
#pragma mark - 赞美诗歌
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self setTopButUI];
    [self chooseVideo];
    
    videoType = 1;//新  格式问题

    self.mutArrayData = [[NSMutableArray alloc]init];
    self.numberPage = 1;
    if ([self.strTitile isEqualToString:@"牧师讲道"]) {
        self.numberComeIn = @"3";
        [self QueryTheCachePreachingVideoAata];
        self.typeChooseBut = [UIButton buttonWithType:UIButtonTypeCustom];
        self.typeChooseBut.frame = CGRectMake(0, 0, 40, 30);
        [self.typeChooseBut setImage:[UIImage imageNamed:@"格式转化"] forState:UIControlStateNormal];
        [self.typeChooseBut addTarget:self action:@selector(clickRightBarButtonItem) forControlEvents:UIControlEventTouchUpInside];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.typeChooseBut];
    }
    if([self.strTitile isEqualToString:@"赞美诗歌"]){
        self.numberComeIn = @"1";
        [self QueryTheCacheToPraiseThePoemIsData :self.numberPage];
    }
    
//    LCPlaylist *playlistTest = _PlaylistMgr.allPlaylists.firstObject;
//    _LCPlayer.songs = playlistTest.allSongs;
    [self creareAVPlay];//取title的值进行判断 ///////////
    self.viewSharePopover.hidden = YES;
    self.viewLow.hidden = YES;
    self.butCancel.hidden = YES;
    [LCFloatingWindow sharedInstance].hidden = NO;
    self.numberRow = -1;
    [self addNSNotificationCenter];
}
#pragma mark - 上面一些按钮的UI
-(void)setTopButUI
{
    self.arrayChoose = @[@"热门",@"讲员",@"机构",@"类别"];
    
    UIView * viewTopChoose = [[UIView alloc]initWithFrame:CGRectMake(WidthScal_320(75), 0, ScreenWidth-WidthScal_320(150), 40)];
    [viewTopChoose.layer setCornerRadius:5];
    [viewTopChoose.layer setMasksToBounds:YES];
    [viewTopChoose.layer setBorderWidth:1.0];
    viewTopChoose.layer.borderColor=[UIColor whiteColor].CGColor;
    self.navigationItem.titleView = viewTopChoose;
    
    self.buttonLeft = [UIButton buttonWithType:UIButtonTypeCustom];
    self.buttonLeft.frame = CGRectMake(0, 0,viewTopChoose.frame.size.width/2,viewTopChoose.frame.size.height);
    if ([self.strTitile isEqualToString:@"牧师讲道"]) {
        [self.buttonLeft setTitle:@"视 频" forState:UIControlStateNormal];
    }else{
        [self.buttonLeft setTitle:@"分 类" forState:UIControlStateNormal];
    }
    self.buttonLeft.tag = 1;
    [self.buttonLeft addTarget:self action:@selector(clcickBut:) forControlEvents:UIControlEventTouchUpInside];
    [viewTopChoose addSubview:self.buttonLeft];
    
    self.buttonRight = [UIButton buttonWithType:UIButtonTypeCustom];
    self.buttonRight.frame = CGRectMake(viewTopChoose.frame.size.width/2, 0, viewTopChoose.frame.size.width/2,viewTopChoose.frame.size.height);
    if ([self.strTitile isEqualToString:@"牧师讲道"]) {
        [self.buttonRight setTitle:@"音 频" forState:UIControlStateNormal];
    }else{
        [self.buttonRight setTitle:@"排行榜" forState:UIControlStateNormal];
    }
    self.buttonRight.tag = 2;
    [self.buttonRight setTitleColor:navColor forState:UIControlStateNormal];
    [self.buttonRight addTarget:self action:@selector(clcickBut:) forControlEvents:UIControlEventTouchUpInside];
    [viewTopChoose addSubview:self.buttonRight];
}
-(void)clcickBut:(UIButton *)but
{
    if (but.tag == 1 && self.numberChoose == 1) {
        return;
    }
    if (but.tag ==2 && self.numberChoose == 2) {
        return;
    }
    if (but.tag == 1) {
        [self chooseVideo];
        [self setCollerview];
        if ([self.strTitile isEqualToString:@"牧师讲道"]) {
#pragma mark - 点击牧师讲道的视频
            self.typeChooseBut.hidden = NO;
          [self.mutArrayData removeAllObjects];
          self.numberComeIn = @"3";
          [self QueryTheCachePreachingVideoAata];
        }
        if ([self.strTitile isEqualToString:@"赞美诗歌"])
        {
#pragma mark - 点击诗歌赞美的分类
            NSLog(@"诗歌赞美的分类");
            [self.mutArrayData removeAllObjects];
            [self ClassificationPoetry :1];
            self.numberComeIn = @"1";
            self.numberPage = 1;
        }
    }
    else
    {
        self.numberChoose = 2;
        self.buttonLeft.backgroundColor = [UIColor whiteColor];
        [self.buttonLeft setTitleColor:navColor forState:UIControlStateNormal];
        self.buttonRight.backgroundColor = navColor;
        [self.buttonRight setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self setTableview];
        [self setViewSharePopover];
        if ([self.strTitile isEqualToString:@"牧师讲道"]) {
#pragma mark - 点击牧师讲道的音频
            self.typeChooseBut.hidden = YES;
            self.numberComeIn = @"5";
            self.numberPage = 1;
            [self.mutArrayData removeAllObjects];
            [self QueryTheCachePriestForTheAudioData:@"hotmusic"];
        }
        if ([self.strTitile isEqualToString:@"赞美诗歌"])
        {
#pragma mark - 点击诗歌赞美的排行榜
            self.numberComeIn = @"2";
            self.numberPage = 1;
            [self.mutArrayData removeAllObjects];
            [self QueryCacheHymnListData :self.numberPage];
        }
    }
}
#pragma mark - 选择视频
-(void)chooseVideo
{
    self.numberChoose = 1;
    self.buttonLeft.backgroundColor = navColor;
    [self.buttonLeft setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.buttonRight.backgroundColor = [UIColor whiteColor];
    [self.buttonRight setTitleColor:navColor forState:UIControlStateNormal];
    [self setCollerview];
}
#pragma mark - 瀑布流的布局
-(void)setCollerview
{
    //    瀑布流
    UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.minimumInteritemSpacing = 15;
    flowLayout.minimumLineSpacing = 15;

    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,NAVIGATION_BAR_HEIGHT,  ScreenWidth, ScreenHeight-NAVIGATION_BAR_HEIGHT-HOME_INDICATOR_HEIGHT-60) collectionViewLayout:flowLayout];
    self.collectionView.delegate   = self;
    self.collectionView.dataSource = self;
    [self.collectionView registerClass:[LSZVideoCollectionViewCell class] forCellWithReuseIdentifier:@"LSZVideoCollectionViewCell"];
    [self.collectionView registerClass:[LSZNewVideoTypeCollectionViewCell class] forCellWithReuseIdentifier:@"LSZNewVideoTypeCollectionViewCell"];
    [self.collectionView registerClass:[LSZMoveCollectionViewCell class] forCellWithReuseIdentifier:@"LSZMoveCollectionViewCell"];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.collectionView];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self RefreshData];
}
#pragma mark - cell大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (videoType == 1&&[self.numberComeIn isEqualToString:@"3"]) {
        return CGSizeMake(ScreenWidth, ScreenWidth*0.556);
    }else{
        CGFloat width = (ScreenWidth- 60-1) / 3;
        return CGSizeMake(width, width+35);
    }
}
#pragma mark - collectionView代理
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.mutArrayData.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (videoType == 1&&[self.numberComeIn isEqualToString:@"3"]) {
        LSZNewVideoTypeCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LSZNewVideoTypeCollectionViewCell" forIndexPath:indexPath];
        LSZPriestPreachedVideoMg * videoMg = nil;
        if (self.mutArrayData.count >indexPath.row) {
            videoMg = self.mutArrayData[indexPath.row];
            [cell.imageViewBack       sd_setImageWithURL:[NSURL URLWithString:videoMg.pic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
            cell.labelName.text = [NSString stringWithFormat:@"%@",videoMg.author];
            cell.labelContent.text = [NSString stringWithFormat:@"%@",videoMg.introduce];
            CGFloat heightContent ;

            if (ScreenWidth == 320) {
                //5
                heightContent = [LSZSpecialPackaging labelAdaptiveAltitude:ScreenWidth-20 height:30 label:cell.labelContent];
            }else if(ScreenWidth == 375){
                // 6 7
                heightContent = [LSZSpecialPackaging labelAdaptiveAltitude:ScreenWidth-20 height:32 label:cell.labelContent];
            }else {
                //plus
                heightContent = [LSZSpecialPackaging labelAdaptiveAltitude:ScreenWidth-20 height:34 label:cell.labelContent];
            }
            CGFloat MaxYContent = CGRectGetMaxY(cell.labelContent.frame);
            CGRect rect = cell.labelContent.frame;
            rect.size.height = heightContent;
            rect.origin.y = MaxYContent-heightContent;
            cell.labelContent.frame = rect;
            NSLog(@"%f>>>>>>>heightContent",heightContent);
            CGRect rectName = cell.labelName.frame;
            if(heightContent >17){
                rectName.origin.y = CGRectGetMinY(cell.labelContent.frame)-5-cell.labelContent.frame.size.height;
            }else{
                rectName.origin.y = CGRectGetMinY(cell.labelContent.frame)-15-cell.labelContent.frame.size.height;
            }
            cell.labelName.frame = rectName;
        }
        return cell;
    }else if ([self.numberComeIn isEqualToString:@"1"]){
        LSZMoveCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LSZMoveCollectionViewCell" forIndexPath:indexPath];
        LSZAudioMg * audioMg = nil;
        audioMg = self.mutArrayData[indexPath.row];
        [cell.imagePicture  sd_setImageWithURL:[NSURL URLWithString:audioMg.image] placeholderImage:[UIImage imageNamed:@"我的_设置_关于"]];
        if ([audioMg.type isEqualToString:@"zhuanji"]) {
            cell.labelName.text = [NSString stringWithFormat:@"%@",audioMg.album_name];
            NSString * str = [NSString stringWithFormat:@"%@",audioMg.artist_name];
            cell.labelIntroduce.text =NullStringjudgment(str);
        }else{
            cell.labelName.text = [NSString stringWithFormat:@"%@",audioMg.singerName];
            [cell.labelName mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(cell.bgview.mas_centerY);
                make.width.equalTo(cell.bgview.mas_width);
                make.height.offset(8);
            }];
        }
        cell.labelTotal.text = [NSString stringWithFormat:@"共%@首",audioMg.total_song];
        cell.labelClick.text = audioMg.hits;
        CGFloat width = [LSZSpecialPackaging getsTheAdaptiveWidth:cell.labelClick sizeMaxWidth:cell.imagePicture.frame.size.width]+3;
        [cell.labelClick mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.offset(width);
        }];
        cell.backgroundColor = RGBColor(236, 236, 236);
        return cell;
    }
    else{
        LSZVideoCollectionViewCell * collectionCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LSZVideoCollectionViewCell" forIndexPath:indexPath];
        LSZPriestPreachedVideoMg * videoMg = nil;
        videoMg = self.mutArrayData[indexPath.row];
        [collectionCell.imageViewCollection  sd_setImageWithURL:[NSURL URLWithString:videoMg.pic] placeholderImage:[UIImage imageNamed:@"placeholder"]];
        collectionCell.labelName.text = [NSString stringWithFormat:@"%@",videoMg.author];
        collectionCell.backgroundColor = [UIColor whiteColor];
        return collectionCell;
    }
}
#pragma mark -瀑布流单元格的点击事件
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    //赞美诗歌_分类
    if ([self.numberComeIn isEqualToString:@"1"]) {
        LSZNewAudioPlayImageAndTableViewVC * vc = [[LSZNewAudioPlayImageAndTableViewVC alloc]init];
        LSZAudioMg * audioMg = nil;
        audioMg = self.mutArrayData[indexPath.row];
        [LCUtils moveAlbumArtistDetailsInterfaceJump:vc audioMg:audioMg typeComeWhere:@"1"];
        vc.lastPageNumberRow = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
        vc.lastSection = [NSString stringWithFormat:@"%ld",(long)indexPath.section-1];
        [self.navigationController pushViewController:vc animated:YES];
    }
    //讲道_视频_详情
    if ([self.numberComeIn isEqualToString:@"3"]) {
        LSZPriestPreachedVideoMg * videoMg = nil;
        videoMg = self.mutArrayData[indexPath.row];
        LSZVideoDetailsVC * vc = [[LSZVideoDetailsVC alloc]init];
        vc.strTitle = videoMg.author;
        vc.imageUrl = videoMg.pic;
        vc.goodsID = [NSString stringWithFormat:@"%ld",(long)videoMg.id_id];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
// 设置最小行间距，也就是前一行与后一行的中间最小间隔
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    if (videoType == 1&&[self.numberComeIn isEqualToString:@"3"]) {
        return 0.0001;
    }else{
        return 1;
    }
}
// 设置最小列间距，也就是左行与右一行的中间最小间隔
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 1;
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    if (videoType == 1&&[self.numberComeIn isEqualToString:@"3"]) {
        return  UIEdgeInsetsMake(0, 10,0,10);
    }else{
        return UIEdgeInsetsMake(15, 15,15,15);
    }
}
#pragma mark - 切换导航的格式
-(void)clickRightBarButtonItem
{
    if(videoType == 1){
        videoType = 2;
    }else{
        videoType = 1;
    }
    [self.collectionView reloadData];
}
#pragma mark - 如果是牧师讲道
-(void)priestSaysTopView
{
    UIView * viewTop= [[UIView alloc]initWithFrame:CGRectMake(0,NAVIGATION_BAR_HEIGHT, ScreenWidth, 55)];
    viewTop.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:viewTop];
    self.viewSmall= [[UIView alloc]initWithFrame:CGRectMake(20, 10, ScreenWidth-40, 40)];
    [self.viewSmall.layer setCornerRadius:5];
    [self.viewSmall.layer setMasksToBounds:YES];
    [self.viewSmall.layer setBorderWidth:1.0];
    self.viewSmall.layer.borderColor=navColor.CGColor;
    [viewTop addSubview:self.viewSmall];
    for (int i = 0; i<4; i++) {
        UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(i *self.viewSmall.frame.size.width/4, 0, self.viewSmall.frame.size.width/4, 40)];
        button.tag = 10+i;
        if (i == 0) {
            self.AudioNumberClass = 1;
            button.backgroundColor = navColor;
            [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        }else{
            button.backgroundColor = [UIColor whiteColor];
            [button setTitleColor:navColor forState:UIControlStateNormal];
        }
        [button setTitle:[NSString stringWithFormat:@"%@",self.arrayChoose[i]] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(clickChooseAudio:) forControlEvents:UIControlEventTouchUpInside];
        [self.viewSmall addSubview:button];
    }
    [LSZSpecialPackaging addThreadWithOtherRGB:self.viewSmall A:self.viewSmall.frame.size.width/4 B:0 C:1 D:self.viewSmall.frame.size.height R:228 G:83 BB:77];
    [LSZSpecialPackaging addThreadWithOtherRGB:self.viewSmall A:self.viewSmall.frame.size.width/2 B:0 C:1 D:self.viewSmall.frame.size.height R:228 G:83 BB:77];
    [LSZSpecialPackaging addThreadWithOtherRGB:self.viewSmall A:3*self.viewSmall.frame.size.width/4 B:0 C:1 D:self.viewSmall.frame.size.height R:228 G:83 BB:77];
}
#pragma mark - 表的布局_______________________
-(void)setTableview
{
    self.tableViewAudio = [[UITableView  alloc]initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT, ScreenWidth, ScreenHeight-NAVIGATION_BAR_HEIGHT-60) style:UITableViewStylePlain];
    if ([self.strTitile isEqualToString:@"牧师讲道"]) {
        self.tableViewAudio.frame = CGRectMake(0, 55+NAVIGATION_BAR_HEIGHT, ScreenWidth, ScreenHeight-55-NAVIGATION_BAR_HEIGHT-60-HOME_INDICATOR_HEIGHT);
        [self priestSaysTopView];
    }else{
        self.tableViewAudio.frame = CGRectMake(0, NAVIGATION_BAR_HEIGHT, ScreenWidth, ScreenHeight-NAVIGATION_BAR_HEIGHT-60-HOME_INDICATOR_HEIGHT);
    }
     self.tableViewAudio.dataSource = self;
    self.tableViewAudio.delegate = self;
    //添加以下代码关闭估算行高
    self.tableViewAudio.estimatedRowHeight = 0;
    self.tableViewAudio.estimatedSectionHeaderHeight = 0;
    self.tableViewAudio.estimatedSectionFooterHeight = 0;
    [self.view addSubview:self.tableViewAudio];
    
    [self.tableViewAudio registerClass:[LSZRandombroadcastHeaderCell class] forHeaderFooterViewReuseIdentifier:@"LSZRandombroadcastHeaderCell"];
    [self.tableViewAudio registerClass:[LSZAudioFrequencyTableViewCell class] forCellReuseIdentifier:@"LSZAudioFrequencyTableViewCell"];
    [self.tableViewAudio registerClass:[LSZNewWithPlusSignAudioTableViewCell class] forCellReuseIdentifier:@"LSZNewWithPlusSignAudioTableViewCell"];
    [self tableviewData];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([self.numberComeIn isEqualToString:@"2"]) {
        if (ScreenWidth == 320) {
            //5
            return 45;
        }else if(ScreenWidth == 375){
            // 6 7
            return 50;
        }else {
            //plus
            return 58;
        }
    }
    return 60;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if([self.numberComeIn isEqualToString:@"6"]||[self.numberComeIn isEqualToString:@"7"]||[self.numberComeIn isEqualToString:@"8"]){
        return 0.001;
    }else{
        return  40;
    }
}
#pragma mark - 音频有几行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.mutArrayData.count;
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if([self.numberComeIn isEqualToString:@"6"]||[self.numberComeIn isEqualToString:@"7"]||[self.numberComeIn isEqualToString:@"8"]){
        UITableViewHeaderFooterView * headerCell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"headerCell"];
        if (!headerCell) {
            headerCell = [[UITableViewHeaderFooterView alloc]initWithReuseIdentifier:@"headerCell"];
        }
        return headerCell;
    }
    else{
        LSZRandombroadcastHeaderCell * cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"LSZRandombroadcastHeaderCell"];
        if (!cell) {
            cell = [[LSZRandombroadcastHeaderCell alloc]initWithReuseIdentifier:@"LSZRandombroadcastHeaderCell"];
        }
        UITapGestureRecognizer * singleTapimageView = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickButRandom:)];
        [cell.imageViewPlay addGestureRecognizer:singleTapimageView];
        
        UITapGestureRecognizer * singleTaplabel = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickButRandom:)];
        [cell.label addGestureRecognizer:singleTaplabel];
        
        [cell.butPaly addTarget:self action:@selector(clickButRandom:) forControlEvents:UIControlEventTouchUpInside];
        return cell;
    }
}
#pragma mark - 点击随机播放
-(void)clickButRandom:(UIButton *)but
{
    LCPlaylist *playlistTest = _PlaylistMgr.allPlaylists.firstObject;
    _LCPlayer.songs = playlistTest.allSongs;
    _LCPlayer.listStatus = LCMusicListStatusAllCycle;//现在是循环播放
    [_LCPlayer playAtIndex:0 isSelectPlay:YES];
}
#pragma mark - 音频的cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([self.numberComeIn isEqualToString:@"2"]) {
#pragma mark - 赞美诗的排行榜的数据加载
        LSZNewWithPlusSignAudioTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZNewWithPlusSignAudioTableViewCell" forIndexPath:indexPath];
        if(self.mutArrayData.count >0){
            LSZleagueTableMg * tableMg = nil;
            tableMg = self.mutArrayData[indexPath.row];
            cell.labelNumber.text = [NSString stringWithFormat:@"%zd",(long)indexPath.row+1];
            cell.labelSong.text = [NSString stringWithFormat:@"%@",tableMg.title];
            cell.labelAlbums.text = [NSString stringWithFormat:@"%@",tableMg.singerName];
//            cell.imageViewHeadset.hidden = YES;
//            cell.labelPlaysNumber.hidden = YES;
            //耳机
            [LSZSpecialPackaging adaptiveWidth:cell.labelAlbums str:cell.labelAlbums.text sizeMaxWidth:ScreenWidth sizeMaxHeight:cell.labelAlbums.frame.size.height];
            CGRect rect = cell.imageViewHeadset.frame;
            rect.origin.x = CGRectGetMaxX(cell.labelAlbums.frame)+10;
            cell.imageViewHeadset.frame = rect;
            //次数
            CGRect rectPlays = cell.labelPlaysNumber.frame;
            rectPlays.origin.x = CGRectGetMaxX(cell.imageViewHeadset.frame)+2;
            rectPlays.size.width = ScreenWidth-CGRectGetMaxX(cell.imageViewHeadset.frame)-10;
            cell.labelPlaysNumber.frame = rectPlays;
            cell.labelPlaysNumber.text = [NSString stringWithFormat:@"%@次",tableMg.clickConversion];
        }
        cell.butMove.tag = indexPath.row +1;
        [cell.butMove addTarget:self action:@selector(clickMoveMusicList:) forControlEvents:UIControlEventTouchUpInside];
        if (_LCPlayer.selectedIndex == indexPath.row && [[LCHistoryDataManager loadOneSongsData] isEqualToString:cell.labelSong.text] && [cell.labelAlbums.text isEqualToString:_LCPlayer.playingSong.singerName]) {
            [cell didSelectRowCellWithIsSystemRed:YES];
            lastClickRow = indexPath.row;
        }else{
            [cell didSelectRowCellWithIsSystemRed:NO];
        }
        return cell;
    }
#pragma mark - 牧师讲道音频的数据加载
    else{
        LSZAudioFrequencyTableViewCell * cell = [[LSZAudioFrequencyTableViewCell alloc]initWithNumberAudioFrequency:1];
        if(self.mutArrayData.count >0){
            LSZPriestPreachedAudioMg * audioMg = nil;
            audioMg =self.mutArrayData[indexPath.row];
            cell.labelNumber.text = [NSString stringWithFormat:@"%ld",(long)indexPath.row+1];
            [cell.imageViewAudio                                 sd_setImageWithURL:[NSURL URLWithString:audioMg.image] placeholderImage:[UIImage imageNamed:@"placeholder"]];
            cell.imageViewHook.image = [UIImage imageNamed:@"placeholder"];
            //热门
            if ([self.numberComeIn isEqualToString:@"5"]) {
                cell.labelTitle.text = [NSString stringWithFormat:@"%@",audioMg.title];
                cell.labelChapters.text = [NSString stringWithFormat:@"%@",audioMg.album];
                cell.butShare.hidden = NO;

                if (_LCPlayer.selectedIndex == indexPath.row && [[LCHistoryDataManager loadOneSongsData]  isEqualToString:cell.labelTitle.text]&&[cell.labelChapters.text isEqualToString:_LCPlayer.playingSong.album]) {
                    [cell clickOnThisSongToPlay:YES];
                    lastClickRow = indexPath.row;
                }else{
                    [cell clickOnThisSongToPlay:NO];
                }
            }
            //讲员
            if ([self.numberComeIn isEqualToString:@"6"]) {
                cell.labelTitle.text = [NSString stringWithFormat:@"%@",audioMg.singerName];
                cell.labelChapters.text = [NSString stringWithFormat:@"%@个专辑%@篇讲道",audioMg.total_album,audioMg.total_song];
                cell.butShare.hidden = YES;
            }
            if ([self.numberComeIn isEqualToString:@"7"]) {
                cell.labelTitle.text = [NSString stringWithFormat:@"%@",audioMg.title];
                cell.labelChapters.text = [NSString stringWithFormat:@"%@个专辑",audioMg.total_album];
                cell.butShare.hidden = YES;
            }
            if ([self.numberComeIn isEqualToString:@"8"]) {
                cell.labelTitle.text = [NSString stringWithFormat:@"%@",audioMg.title];
                cell.labelChapters.text = [NSString stringWithFormat:@"%@个讲道",audioMg.total_music];
                cell.butShare.hidden = YES;
            }
        }
        cell.butShare.tag = indexPath.row;
        [cell.butShare addTarget:self action:@selector(clickButShare:) forControlEvents:UIControlEventTouchUpInside];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
}
#pragma mark - 单元格的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //机构和类别
    if (([self.numberComeIn isEqualToString:@"7"]||[self.numberComeIn isEqualToString:@"8"])) {
        LSZPriestPreachedAudioMg * audioMg = nil;
        audioMg =self.mutArrayData[indexPath.row];
        
        LSZThemesAlbumsVC * vc = [[LSZThemesAlbumsVC alloc]init];
        vc.titleStr = audioMg.title;
        
        if ([self.numberComeIn isEqualToString:@"7"]) {
            vc.typeStr = @"jigou";
        }
        if ([self.numberComeIn isEqualToString:@"8"]) {
            vc.typeStr = @"fenlei";
        }
        vc.optStr = @"2";
        vc.parentId = audioMg.id_id;
        if ([self.numberComeIn isEqualToString:@"7"]) {
            vc.lastClassNumberRow = @"3";
        }
        if ([self.numberComeIn isEqualToString:@"8"]) {
            vc.lastClassNumberRow = @"4";
        }
        [self.navigationController pushViewController:vc animated:YES];
    }
    if ([self.numberComeIn isEqualToString:@"6"])
    {
        //讲员的详情
        LSZPriestPreachedAudioMg * audioMg = nil;
        audioMg =self.mutArrayData[indexPath.row];
        
        LSZPlayThemeVC * vc = [[LSZPlayThemeVC alloc]init];
        vc.titleStr = audioMg.singerName;
        vc.typeStr = @"jiangyuan";
        vc.optStr = @"2";
        vc.parentId = audioMg.id_id;
    NSLog(@"%@<<<<<<<<<<$$$$$$$$$$$$$$$$$$$$%@",audioMg.id_id,audioMg.singerName);
        vc.lastPageNumberRow = [NSString stringWithFormat:@"%ld",(long)indexPath.row];
        vc.lastClassNumberRow = @"2";
        [self.navigationController pushViewController:vc animated:YES];
    }
#pragma mark - 诗歌排行榜2  音频是5
    if([self.numberComeIn isEqualToString:@"2"] ||[self.numberComeIn isEqualToString:@"5"]){
        LCPlaylist *playlistTest = _PlaylistMgr.allPlaylists.firstObject;
        _LCPlayer.songs = playlistTest.allSongs;
        
        if([self.numberComeIn isEqualToString:@"2"]){
        _LCPlayer.valueDistinguish = @"2_1";
            LSZleagueTableMg * tableMg = nil;
            if (self.mutArrayData.count > indexPath.row) {
                tableMg = self.mutArrayData[indexPath.row];
                [LSZRequestData songClickOnTheDataUpdates:tableMg.id_id :^(BOOL isOk, NSString * str, NSDictionary * dic) {
                    if (isOk == YES) {
                        //点击数更新OK
                        tableMg.click = [NSString stringWithFormat:@"%d",[tableMg.click intValue]+1];
                        tableMg.clickConversion  = [LSZSpecialPackaging theNumberViewsForTheAlbumAhanges:tableMg.click];
                    }
                }];
            }
        }
        if([self.numberComeIn isEqualToString:@"5"])
        {
            _LCPlayer.valueDistinguish = @"6_1";
        }
      
        [_LCPlayer playAtIndex:indexPath.row isSelectPlay:YES];//播放歌曲
        NSInteger lastRow = lastClickRow;
        lastClickRow = (NSInteger)indexPath.row;
        if (lastRow > 0||lastRow == 0) {
            NSIndexPath *indexPath=[NSIndexPath indexPathForRow:lastRow inSection:0];
            [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
        }
        [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
    }
}
#pragma mark - _______________下面都是请求____________________
#pragma mark - 牧师讲道的视频 先查询缓存的有没有讲道视频的数据
-(void)QueryTheCachePreachingVideoAata
{
    __weak typeof(self) weakSelf = self;
    [LSZCacheHandling initWithfindPlist:jiangdao_shipin :^(BOOL isOk, NSDictionary * dic) {
        if (isOk == YES) {
            LSZPriestPreachedVideoManager * MG  = [[LSZPriestPreachedVideoManager alloc]initWithDicPriestPreachedVideoManager:dic];
            weakSelf.mutArrayData = MG.mutDataArray;
            [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                [weakSelf.collectionView reloadData];
            }];
        }else{
            pageVideo = 1;
            [self ThePriestPreachedVideo :pageVideo];
        }
    }];
}
#pragma mark - 牧师讲道的视频__数据请求________
-(void)ThePriestPreachedVideo :(NSInteger)page
{
    __weak typeof(self) weakSelf = self;
    [LSZRequestResolutionDic initWithListOfNewPastoralists :[NSString stringWithFormat:@"%ld",(long)page]:^(BOOL isOk, NSString * str, LSZPriestPreachedVideoManager * videoManager) {
        if (isOk == YES) {
            if (page == 1) {
                [weakSelf.mutArrayData removeAllObjects];
                [weakSelf.mutArrayData addObjectsFromArray:videoManager.mutDataArray];
            }else{
                [weakSelf.mutArrayData addObjectsFromArray:videoManager.mutDataArray];
            }
            if(videoManager.mutDataArray.count == 0){
                [weakSelf.collectionView.mj_footer endRefreshingWithNoMoreData];
            }
            [weakSelf.collectionView reloadData];
        }else{
            [self setStringWarning:str];
        }
    }];
}
#pragma mark - 牧师讲道的音频下几个小分类的请求_数据请求________________
#pragma mark - 查询有没有数据
-(void)QueryTheCachePriestForTheAudioData :(NSString *)type
{
    //jiangdao_yinpin
    __weak typeof(self) weakSelf = self;
    NSString * strType = [NSString stringWithFormat:@"%@_%@",jiangdao_yinpin,type];
    [LSZCacheHandling initWithfindPlist:strType :^(BOOL isOk, NSDictionary * dic) {
        if (isOk == YES) {
            LSZPriestPreachedAudioManager * MG  = [[LSZPriestPreachedAudioManager alloc]initWithDicPriestPreachedAudioManager:dic type:type value:@"1"];
         
            [weakSelf.mutArrayData removeAllObjects];
            [weakSelf.mutArrayData setArray:MG.mutDataArray];
            
            if ([weakSelf.numberComeIn isEqualToString:@"5"]) {
                [weakSelf.mutAllOriginalArrayData removeAllObjects];
                [weakSelf.mutAllOriginalArrayData setArray:MG.historyArrayData];
            }
 //播放
            if([weakSelf.numberComeIn isEqualToString:@"5"]){
                NSString * distinguishValue =  [LSZSpecialPackaging addPlaylistWithArrayData:weakSelf.mutAllOriginalArrayData];
                if ([distinguishValue isEqualToString:@"6_1"]) {
                    LCPlaylist *playlistTest = _PlaylistMgr.allPlaylists.firstObject;
                    _LCPlayer.songs = playlistTest.allSongs;
                }
            }
 
            [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                [self.tableViewAudio reloadData];
            }];
        }else{
            [self loadMusicPriestPreached:type];
        }
    }];
}
#pragma mark - 请求的数据
- (void)loadMusicPriestPreached:(NSString *)type
{
     __weak typeof(self) weakSelf = self;
    [LSZRequestResolutionDic initWithSaysAudio:[NSString stringWithFormat:@"%ld",(long)self.numberPage] type:type :^(BOOL isOK, NSString * str, LSZPriestPreachedAudioManager * AudioManager) {
        if (isOK == YES) {
             if (weakSelf.numberPage == 1) {
                [weakSelf.mutArrayData removeAllObjects];
                [weakSelf.mutArrayData setArray:AudioManager.mutDataArray];
                 if ([weakSelf.numberComeIn isEqualToString:@"5"]) {
                     [weakSelf.mutAllOriginalArrayData removeAllObjects];
                     [weakSelf.mutAllOriginalArrayData setArray:AudioManager.historyArrayData];
                 }
            }else{
                [weakSelf.mutArrayData addObjectsFromArray:AudioManager.mutDataArray];
                if ([weakSelf.numberComeIn isEqualToString:@"5"]) {
                    [weakSelf.mutAllOriginalArrayData addObjectsFromArray:AudioManager.historyArrayData];
                }
            }
            if([weakSelf.numberComeIn isEqualToString:@"5"]){
                NSString * distinguishValue =  [LSZSpecialPackaging addPlaylistWithArrayData:weakSelf.mutAllOriginalArrayData];
                if ([distinguishValue isEqualToString:@"6_1"]) {
                    LCPlaylist *playlistTest = _PlaylistMgr.allPlaylists.firstObject;
                    _LCPlayer.songs = playlistTest.allSongs;
                }
            }
            [weakSelf.tableViewAudio reloadData];
        }else{
            [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",str]];
            [SVProgressHUD dismissWithDelay:1];
        }
    }];
}
#pragma mark - 牧师讲道 音频下的分类选择
-(void)clickChooseAudio:(UIButton *)but
{
    if(but.tag == 10){
        if(self.AudioNumberClass == 1){
            return;
        }
        self.AudioNumberClass = 1;
        [self AudioNumberClassChooseBut];
    }else if (but.tag == 11){
        if(self.AudioNumberClass == 2){
            return;
        }
        self.AudioNumberClass = 2;
        [self AudioNumberClassChooseBut];
    }else if (but.tag == 12){
        if(self.AudioNumberClass == 3){
            return;
        }
        self.AudioNumberClass = 3;
        [self AudioNumberClassChooseBut];
    }else{
        if(self.AudioNumberClass == 4){
            return;
        }
        self.AudioNumberClass = 4;
        [self AudioNumberClassChooseBut];
    }
}
#pragma mark - 在牧师讲道下的音频下   下面几个小类的选择
-(void)AudioNumberClassChooseBut
{
    self.viewSharePopover.hidden = YES;
    self.viewLow.hidden = YES;
    self.butCancel.hidden = YES;
    [LCFloatingWindow sharedInstance].hidden = NO;
    UIButton * butonHot = [self.viewSmall viewWithTag:10];
    UIButton * butonSpeaker = [self.viewSmall viewWithTag:11];
    UIButton * butonMechanism = [self.viewSmall viewWithTag:12];
    UIButton * butonClass = [self.viewSmall viewWithTag:13];
    if (self.AudioNumberClass == 1) {
        //选择热门
        butonHot.backgroundColor = navColor;
        [butonHot setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        butonSpeaker.backgroundColor = [UIColor whiteColor];
        [butonSpeaker setTitleColor:navColor forState:UIControlStateNormal];
        butonMechanism.backgroundColor = [UIColor whiteColor];
        [butonMechanism setTitleColor:navColor forState:UIControlStateNormal];
        butonClass.backgroundColor = [UIColor whiteColor];
        [butonClass setTitleColor:navColor forState:UIControlStateNormal];
        self.numberPage = 1;
        self.numberComeIn = @"5";
        //这个地方添加它  是为了解决  从讲员 机构 类别他们的子界面播放之后  回到热门随机播放出现问题
        LCPlaylist *playlistTest = _PlaylistMgr.allPlaylists.firstObject;
        _LCPlayer.songs = playlistTest.allSongs;
        [self QueryTheCachePriestForTheAudioData:@"hotmusic"];
    }else if (self.AudioNumberClass == 2){
        //讲员
        butonHot.backgroundColor = [UIColor whiteColor];
        [butonHot setTitleColor:navColor forState:UIControlStateNormal];
        butonSpeaker.backgroundColor = navColor;
        [butonSpeaker setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        butonMechanism.backgroundColor = [UIColor whiteColor];
        [butonMechanism setTitleColor:navColor forState:UIControlStateNormal];
        butonClass.backgroundColor = [UIColor whiteColor];
        [butonClass setTitleColor:navColor forState:UIControlStateNormal];
        self.numberPage = 1;
        self.numberComeIn = @"6";
        [self QueryTheCachePriestForTheAudioData:@"jiangyuan"];
    }else if (self.AudioNumberClass == 3){
        //机构
        butonHot.backgroundColor = [UIColor whiteColor];
        [butonHot setTitleColor:navColor forState:UIControlStateNormal];
        butonSpeaker.backgroundColor = [UIColor whiteColor];
        [butonSpeaker setTitleColor:navColor forState:UIControlStateNormal];
        butonMechanism.backgroundColor = navColor;
        [butonMechanism setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        butonClass.backgroundColor = [UIColor whiteColor];
        [butonClass setTitleColor:navColor forState:UIControlStateNormal];
        self.numberPage = 1;
        self.numberComeIn = @"7";
        [self QueryTheCachePriestForTheAudioData:@"jigou"];
    }else  {
        //类别
        butonHot.backgroundColor = [UIColor whiteColor];
        [butonHot setTitleColor:navColor forState:UIControlStateNormal];
        butonSpeaker.backgroundColor = [UIColor whiteColor];
        [butonSpeaker setTitleColor:navColor forState:UIControlStateNormal];
        butonMechanism.backgroundColor = [UIColor whiteColor];
        [butonMechanism setTitleColor:navColor forState:UIControlStateNormal];
        butonClass.backgroundColor = navColor;
        [butonClass setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.numberPage = 1;
        self.numberComeIn = @"8";
        [self QueryTheCachePriestForTheAudioData:@"fenlei"];
    }
}
#pragma mark - 赞美诗歌的分类数据请求___________________________
#pragma mark - 赞美诗歌的分类缓存查询
-(void)QueryTheCacheToPraiseThePoemIsData :(NSInteger)number
{
    __weak typeof(self) weakSelf = self;
    NSString * str  = [NSString stringWithFormat:@"%@_%@_%@",shouye_yinpin,@"歌手",@"geshou"];
    [LSZCacheHandling initWithfindPlist:str :^(BOOL isOk, NSDictionary * dic) {
        if (isOk == YES) {
            LSZAudioManager * MG  = [[LSZAudioManager alloc]initWithAudioManager:dic];
            [weakSelf.mutArrayData removeAllObjects];                    [weakSelf.mutArrayData addObjectsFromArray:MG.mutDataArray];
            [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                [weakSelf.collectionView  reloadData];
            }];
        }else{
            [self ClassificationPoetry:number];
        }
    }];
//    __weak typeof(self) weakSelf = self;
//    if (number == 1) {
//        [LSZCacheHandling initWithfindPlist:zanmei_fenlei :^(BOOL isOk, NSDictionary * dic) {
//            if (isOk == YES) {
//                LSZClassificationPraiseManager * MG  = [[LSZClassificationPraiseManager alloc]initWithClassificationPraiseManager:dic];
//                [weakSelf.mutArrayData removeAllObjects];                [weakSelf.mutArrayData setArray:MG.mutDataArray];
//                [[NSOperationQueue mainQueue] addOperationWithBlock:^{
//                    [weakSelf.collectionView reloadData];
//                }];
//            }else{
//                [self ClassificationPoetry:number];
//            }
//        }];
//    }else
//    {
//        [self ClassificationPoetry:number];
//    }
}
#pragma mark - 赞美诗歌分类的数据请求
-(void)ClassificationPoetry :(NSInteger)number
{
    __weak typeof(self) weakSelf = self;
    [LSZRequestResolutionDic audioMoreClassification:[NSString stringWithFormat:@"%ld",(long)number] type:@"geshou" chooseTitleValue:@"歌手/牧师" :^(BOOL isOK, NSString * Str, LSZAudioManager *audioManager) {
        if (isOK == YES) {
            if (number == 1) {
                [weakSelf.mutArrayData removeAllObjects];
                [weakSelf.mutArrayData addObjectsFromArray:audioManager.mutDataArray];
            }else{
                [weakSelf.mutArrayData addObjectsFromArray:audioManager.mutDataArray];
            }
            if(audioManager.mutDataArray.count == 0){
                [weakSelf.collectionView .mj_footer endRefreshingWithNoMoreData];
            }
            [weakSelf.collectionView  reloadData];
        }else{
            [self setStringWarning:Str];
        }
    }];
//    [LSZRequestResolutionDic initWithClassificationOfPraise:[NSString stringWithFormat:@"%ld",(long)number] :^(BOOL isOk, NSString * str, LSZClassificationPraiseManager * PraiseManager) {
//        if (isOk == YES) {
//            if (number == 1) {
//                [weakSelf.mutArrayData removeAllObjects];
//                [weakSelf.mutArrayData setArray:PraiseManager.mutDataArray];
//            }else{
//                [weakSelf.mutArrayData addObjectsFromArray:PraiseManager.mutDataArray];
//            }
//            [weakSelf.collectionView reloadData];
//        }
//        else{
//            [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",str]];
//            [SVProgressHUD dismissWithDelay:1];
//        }
//    }];
}
-(NSMutableArray *)mutAllOriginalArrayData
{
    if (_mutAllOriginalArrayData == nil) {
        _mutAllOriginalArrayData = [[NSMutableArray alloc]init];
    }
    return _mutAllOriginalArrayData;
}
#pragma mark - 赞美诗排行榜查看是否有缓存
-(void)QueryCacheHymnListData :(NSInteger)number
{
    __weak typeof(self) weakSelf = self;
    [LSZCacheHandling initWithfindPlist:newZanmei_paihangbang :^(BOOL isOk, NSDictionary * dic) {
        if (isOk == YES) {
            LSZleagueTableManager * MG  = [[LSZleagueTableManager alloc]initWithleagueTableManager:dic page:@"1"];
            [weakSelf.mutArrayData removeAllObjects];
            [weakSelf.mutArrayData setArray:MG.mutDataArray];

            [weakSelf.mutAllOriginalArrayData removeAllObjects];
            [weakSelf.mutAllOriginalArrayData setArray:MG.historyArrayData];
            NSString * distinguishValue =  [LSZSpecialPackaging addPlaylistWithArrayData:weakSelf.mutAllOriginalArrayData];
            if ([distinguishValue isEqualToString:@"22_1"]) {
                LCPlaylist *playlistTest = _PlaylistMgr.allPlaylists.firstObject;
                _LCPlayer.songs = playlistTest.allSongs;
            }
            [weakSelf.tableViewAudio reloadData];
            [[NSOperationQueue mainQueue] addOperationWithBlock:^{
                [self.tableViewAudio reloadData];
            }];
        }else{
            [self leagueTable:number];
        }
    }];
}
#pragma mark - 赞美诗的排行榜 1
-(void)leagueTable :(NSInteger)number
{
    __weak typeof(self) weakSelf = self;
    [LSZRequestResolutionDic rankingData:[NSString stringWithFormat:@"%ld",(long)number] :^(BOOL isOk, NSString * str, LSZleagueTableManager *TableManager) {
        if (isOk == YES) {
            if (number == 1) {
                [weakSelf.mutArrayData removeAllObjects];
                [weakSelf.mutArrayData setArray:TableManager.mutDataArray];

                [weakSelf.mutAllOriginalArrayData removeAllObjects];
                [weakSelf.mutAllOriginalArrayData setArray:TableManager.historyArrayData];
            }else{
                [weakSelf.mutArrayData addObjectsFromArray:TableManager.mutDataArray];
                [weakSelf.mutAllOriginalArrayData addObjectsFromArray:TableManager.historyArrayData];
            }
            NSString * distinguishValue =  [LSZSpecialPackaging addPlaylistWithArrayData:weakSelf.mutAllOriginalArrayData];
            if ([distinguishValue isEqualToString:@"22_1"]) {
                LCPlaylist *playlistTest = _PlaylistMgr.allPlaylists.firstObject;
                _LCPlayer.songs = playlistTest.allSongs;
            }
            if(TableManager.mutDataArray.count == 0){
                [weakSelf.tableViewAudio.mj_footer endRefreshingWithNoMoreData];
            }
            [weakSelf.tableViewAudio reloadData];
        }else{
            [SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"%@",str]];
            [SVProgressHUD dismissWithDelay:1];
        }
    }];
}
#pragma mark - 上啦加载更多  下拉刷新
-(void)RefreshData
{
    //赞美诗 瀑布流的上下拉
    self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        if ([self.numberComeIn isEqualToString:@"1"]) {
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                // 刷新表格  和结束刷新
                // 进入刷新状态后会自动调用这个block
                self.numberPage = 1;
                //赞美诗的分类
                [self QueryTheCacheToPraiseThePoemIsData:self.numberPage];
                [self.collectionView.mj_header endRefreshing];
            });
        }else{
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                pageVideo = 1;
                [self ThePriestPreachedVideo:pageVideo];
                [self.collectionView.mj_header endRefreshing];
            });
        }
    }];
    // 上拉刷新
    self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        if ([self.numberComeIn isEqualToString:@"1"]) {
            // 进入刷新状态后会自动调用这个block
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                // 刷新表格  和结束刷新
                self.numberPage++;
                //赞美诗的分类
                [self ClassificationPoetry:self.numberPage];
                [self.collectionView.mj_footer endRefreshing];
            });
        }else{
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                 pageVideo ++;
                 [self ThePriestPreachedVideo:pageVideo];
                 [self.collectionView.mj_footer endRefreshing];
            });
        }
    }];
}
-(void)tableviewData
{
    //表的上下拉
    self.tableViewAudio.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            // 进入刷新状态后会自动调用这个block
            self.numberPage = 1;
            //赞美诗排行榜
            if ([self.numberComeIn isEqualToString:@"2"]) {
                [self QueryCacheHymnListData:self.numberPage];
            }
            //讲道音频下的几个小分类
            if ([self.numberComeIn isEqualToString:@"5"]) {
                [self QueryTheCachePriestForTheAudioData:@"hotmusic"];
            }
            if ([self.numberComeIn isEqualToString:@"6"]) {
                [self QueryTheCachePriestForTheAudioData:@"jiangyuan"];
            }
            if ([self.numberComeIn isEqualToString:@"7"]) {
                [self QueryTheCachePriestForTheAudioData:@"jigou"];
            }
            if ([self.numberComeIn isEqualToString:@"8"]) {
                [self QueryTheCachePriestForTheAudioData:@"fenlei"];
            }
            [self.tableViewAudio.mj_header endRefreshing];
        });
    }];
    // 上拉刷新
    self.tableViewAudio.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            // 进入刷新状态后会自动调用这个block
            self.numberPage++;
            //赞美诗的排行榜
            if ([self.numberComeIn isEqualToString:@"2"]) {
                [self leagueTable:self.numberPage];
            }
            if ([self.numberComeIn isEqualToString:@"5"]) {
                [self loadMusicPriestPreached:@"hotmusic"];
            }
            if ([self.numberComeIn isEqualToString:@"6"]) {
                [self loadMusicPriestPreached:@"jiangyuan"];
            }
            if ([self.numberComeIn isEqualToString:@"7"]) {
                [self loadMusicPriestPreached:@"jigou"];
            }
            if ([self.numberComeIn isEqualToString:@"8"]) {
                [self loadMusicPriestPreached:@"fenlei"];
            }
            [self.tableViewAudio.mj_footer endRefreshing];
        });
    }];
}
#pragma mark - 分享弹出来的view
-(void)setViewSharePopover
{
    [LSZSpecialPackaging initAlterView:self.view :^(UIView * viewBack,UIView * viewLow, UIButton * buttonFriends, UIButton * buttonFriendsCircle, UIButton * buttonDownload, UIButton * butCancel) {
        _viewSharePopover = viewBack;
        [self.view bringSubviewToFront:_viewSharePopover];
        [self.tableViewAudio bringSubviewToFront:_viewSharePopover];

        self.viewLow = viewLow;
        [self.view bringSubviewToFront:self.viewLow];
        [self.tableViewAudio bringSubviewToFront:self.viewLow];
        
        self.butCancel = butCancel;
        [self.view bringSubviewToFront:self.butCancel];
        [self.tableViewAudio bringSubviewToFront:self.butCancel];
        
        self.viewSharePopover.hidden = YES;
        self.viewLow.hidden = YES;
        self.butCancel.hidden = YES;
        [LCFloatingWindow sharedInstance].hidden = NO;
        
        [buttonFriends addTarget:self action:@selector(clickShareWeiXin) forControlEvents:UIControlEventTouchUpInside];
        [buttonFriendsCircle addTarget:self action:@selector(clickShareWeiXinFriendsCircle) forControlEvents:UIControlEventTouchUpInside];
        [buttonDownload addTarget:self action:@selector(clickDoenload) forControlEvents:UIControlEventTouchUpInside];
        [butCancel addTarget:self action:@selector(clickButCancel) forControlEvents:UIControlEventTouchUpInside];
    }];
}
#pragma mark - 点击的哪一行的要分享
-(void)clickButShare :(UIButton *)but
{
    self.shareAndDownloadNumberRow = but.tag;
    if(self.numberRow == but.tag){
        self.viewSharePopover.hidden = YES;
        self.viewLow.hidden = YES;
        self.butCancel.hidden = YES;
        [LCFloatingWindow sharedInstance].hidden = NO;
        self.numberRow = -1;
    }else{
        self.viewSharePopover.hidden = NO;
        self.viewLow.hidden = NO;
        self.butCancel.hidden = NO;
        [LCFloatingWindow sharedInstance].hidden = YES;
        self.numberRow = but.tag;
    }
}
#pragma mark - 点击微信分享好友
-(void)clickShareWeiXin
{
    NSString * strUrl = [[NSString alloc]init];
    NSString * strTitle = [[NSString alloc]init];
#pragma mark - 赞美诗的排行榜的数据加载
    if ([self.numberComeIn isEqualToString:@"2"]) {
        LSZleagueTableMg * tableMg = nil;
        tableMg = self.mutArrayData[self.shareAndDownloadNumberRow];
        strUrl = tableMg.fileUrl;
        strTitle = tableMg.title;
    }else{
        LSZPriestPreachedAudioMg * audioMg = nil;
        audioMg =self.mutArrayData[self.shareAndDownloadNumberRow];
        strUrl = audioMg.fileUrl;
        strTitle = audioMg.title;
    }
    NSArray* imageArray = @[[UIImage imageNamed:@"placeholder"]];
    [LSZSpecialPackaging shareWXWithViewController:self imageArray:imageArray url:strUrl title:strTitle contentMessage:@"" type:0];
    [self clickButCancel];
}
#pragma mark - 点击微信分享朋友圈
-(void)clickShareWeiXinFriendsCircle
{
    NSString * strUrl = [[NSString alloc]init];
    NSString * strTitle = [[NSString alloc]init];
    if ([self.numberComeIn isEqualToString:@"2"]) {
        LSZleagueTableMg * tableMg = nil;
        tableMg = self.mutArrayData[self.shareAndDownloadNumberRow];
        strUrl = tableMg.fileUrl;
        strTitle = tableMg.title;
    }else{
        LSZPriestPreachedAudioMg * audioMg = nil;
        audioMg =self.mutArrayData[self.shareAndDownloadNumberRow];
        strUrl = audioMg.fileUrl;
        strTitle = audioMg.title;
    }
    NSArray* imageArray = @[[UIImage imageNamed:@"placeholder"]];
    [LSZSpecialPackaging shareWXWithViewController:self imageArray:imageArray url:strUrl title:strTitle contentMessage:@"" type:1];
    [self clickButCancel];
}
#pragma mark - 点击下载的按钮
-(void)clickDoenload
{
    LSZPriestPreachedAudioMg * audioMg = nil;
    audioMg = self.mutArrayData[self.shareAndDownloadNumberRow];
    NSDictionary *json = [audioMg yy_modelToJSONObject];
    JKSongsMessStatus *song = [JKSongsMessStatus yy_modelWithJSON:json];
    [kNetworkTool downloadSongWithUrl:song];
    [self clickButCancel];
    NSLog(@"点击下载的按钮的点击事件");
}
#pragma mark - 分享或者下载的view   下落
-(void)clickButCancel
{
    _viewSharePopover.hidden = YES;
    self.viewLow.hidden = YES;
    self.butCancel.hidden = YES;
    [LCFloatingWindow sharedInstance].hidden = NO;
    self.numberRow = -1;
}
#pragma mark - 新的分享和收藏
-(void)clickMoveMusicList:(UIButton *)butMove
{
    self.cliclMoveWhereRow = butMove.tag - 1;
    LSZleagueTableMg * mg = nil;
    mg = self.mutArrayData[self.cliclMoveWhereRow];
    LSZPopoverViewController * vc = [[LSZPopoverViewController alloc]init];
    [vc show];
    [vc selectIndexRowWith:2];//布局
    [vc getMusicId:mg.id_id];
    [vc distinguishType:@"3"];
    [vc fromWhichInterface:@"LSZPraisePoetryChartsViewController"];
}
#pragma mark  - 分享
-(void)addNSNotificationCenter
{
    NSString * stringCollection = [NSString stringWithFormat:@"%@Collection",@"LSZPraisePoetryChartsViewController"];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MusicListCollection:) name:stringCollection object:nil];//收藏歌曲成功的通知
    NSString * strShare = [NSString stringWithFormat:@"%@",@"LSZPraisePoetryChartsViewController"];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(InfoNotificationMusicListShare) name:strShare object:nil];//点击分享歌曲的通知
    NSString * strDownload = [NSString stringWithFormat:@"%@Download",@"LSZPraisePoetryChartsViewController"];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(InfoNotificationMusicListDownload) name:strDownload object:nil];//点击下载的通知
    NSString * stringLogin = [NSString stringWithFormat:@"%@Login",@"LSZPraisePoetryChartsViewController"];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(InfoNotificationMusicListLogin) name:stringLogin object:nil];//点击收藏  用户没登录
    //安装播放歌曲发生变化的通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MusicListPlayerPlayingSongDidChangedNotification:) name:LCMusicPlayerPlayingSongDidChangedNotification object:_LCPlayer];
}
-(void)MusicListCollection:(NSNotification *)notification
{
    NSDictionary * diction = notification.userInfo;
    if ([diction[@"ok"] isEqualToString:@"YES"]) {
        [self setStringWarning:@"收藏成功!"];
    }else{
        [self setStringWarning:diction[@"str"]];
    }
}
- (void)InfoNotificationMusicListShare {
    LSZleagueTableMg * mg = nil;
    mg = self.mutArrayData[self.cliclMoveWhereRow];
    [self shareAudioWithImageArray:@[mg.image] url:mg.fileUrl musicWebURL:mg.shareUrl title:mg.title contentMessage:mg.singerName type:(SSDKContentTypeAudio)];
}
#pragma mark - 下载
-(void)InfoNotificationMusicListDownload
{
    JKSongsMessStatus *songsMessStatus;
    LSZleagueTableMg * mg = nil;
    mg = self.mutArrayData[self.cliclMoveWhereRow];
    NSDictionary *json = [mg yy_modelToJSONObject];
    songsMessStatus = [JKSongsMessStatus yy_modelWithJSON:json];
    [kNetworkTool downloadSongWithUrl:songsMessStatus];//下载歌曲文件
}
#pragma mark - 收到通知  用户未登录
-(void)InfoNotificationMusicListLogin
{
    if([[_UserM usercode] isEqualToString:@""]){
        pushAccLoginVC;
    }
}
- (void)MusicListPlayerPlayingSongDidChangedNotification:(NSNotification *)notification {
    [self.tableViewAudio reloadData];
}
- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
